
function setCurrent() {
    var _current = 0;
    return _current;
};

function scrollImgObj(obj) {

    var current = setCurrent();
    function AutoScroll(scrollObj, obj){
        switch (obj) {//判断点击的按钮状态
            case "next":
                current++;
                break;
            case "prev":
                current--;
                break;
        }

        var $scroll = $(scrollObj),
            _length = $scroll.find('li').length,
            w = $scroll.find('li').eq(0).width();

        var win = $(window).width();
        var leftVal = current * w;
        var ulWidth = _length * w;

        $scroll.width(ulWidth);
        $scroll.animate({left:-leftVal},1000,function(){
            //把第一个li丢最后面去
            if(win+leftVal > ulWidth-w){
                $scroll.css({left:0}).find("li:first").appendTo($scroll);
                current=0;
            }
        });
    }
    //两秒后调用
    function scrollObj() {
        AutoScroll(obj,'next');
    }

    var _scrolling=setInterval(scrollObj,2000);
    $(obj).hover(function(){
        //鼠标移动DIV上停止
        clearInterval(_scrolling);
    },function(){
        //离开继续调用
        _scrolling=setInterval(scrollObj,2000);
    });
}

// 教学风采
$(function(){
    //两秒后调用

    scrollImgObj('#teacher-list ul');
    scrollImgObj('#student-list ul');
});
